import { celebrate, Joi } from 'celebrate'

const urlRegex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/

export const loginValidator = celebrate({
  body: Joi.object().keys({
    email: Joi.string().required().email({ tlds: { allow: false } }),
    password: Joi.string().required(),
  }),
})
export const createUserValidator = celebrate({
  body: Joi.object().keys({
    name: Joi.string().required().min(2).max(30),
    email: Joi.string().required().email({ tlds: { allow: false } }),
    password: Joi.string().required(),
    accessLevel: Joi.string().required()
  }),
})
export const getCurrentUserValidator = celebrate({
  params: Joi.object().keys({
    userId: Joi.string().hex().length(24),
  }),
})
export const updateUserValidator = celebrate({
  body: Joi.object().keys({
    name: Joi.string().required().min(2).max(30),
    email: Joi.string().required().email({ tlds: { allow: false } }),
  }),
})
export const createEmployeeValidator = celebrate({
  body: Joi.object().keys({
    firstName: Joi.string().required().min(2).max(30),
    lastName: Joi.string().required().min(2).max(30),
    birthDay: Joi.date().required(),
    comment: Joi.string(),
    config: Joi.object(),
    isActive: Joi.binary().required(),
    email: Joi.string().email({ tlds: { allow: false } }),
    phone: Joi.string(),
    telegram: Joi.string()
  })
})
export const deleteEmployeeValidator = celebrate({
  body: Joi.object().keys({
    isActive: Joi.binary().required()
  })
})
export const updateEmployeeValidator = celebrate({
  body: Joi.object().keys({
    firstName: Joi.string().required().min(2).max(30),
    lastName: Joi.string().required().min(2).max(30),
    birthDay: Joi.date().required(),
    comment: Joi.string(),
    config: Joi.object(),
    isActive: Joi.binary().required(),
    email: Joi.string().email({ tlds: { allow: false } }),
    phone: Joi.string(),
    telegram: Joi.string()
  })
})

